<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	
	<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
	<link href="resources/js/selectJs/select2.css" rel="stylesheet"/>
	<script src="resources/js/selectJs/select2.js"></script>
	
	<script type="text/javascript">
		$(document).ready( function() {
			$("#contents_no").select2();
		});
		
		function selectAd() {
			var conNum = $("#contents_no").val();
			var conTitle = $("#title_" + conNum ).val();
			alert( "no : " + conNum + "\n" + "광고명 : " + conTitle );
			$("input[name=contents_no]", opener.document ).val( conNum );
			$("#contents_lb", opener.document ).val( conTitle );
			self.close();
		}
	</script>
	
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<%
request.setCharacterEncoding( "UTF-8" );
response.setCharacterEncoding( "UTF-8" );
response.setContentType( "text/html; charset=UTF-8" );
%>

<title>꽁알 Administrator</title>
</head>
<body>

	<table align="center" cellpadding="10">
	<c:if test="${listSize > 0 }">
		<tr>
			<td align="center" colspan="2">광고 선택</td>
		</tr>
		<tr>
			<td align="center">
				<select id="contents_no" style="width:180px;">
					<c:forEach var="list" items="${conList }">
						<option value="${list.no }">${list.title }</option>
					</c:forEach>
				</select>
				
				<c:forEach var="list" items="${conList }">
					<input type="hidden" id="title_${list.no }" value="${list.title }"/>
				</c:forEach>
			</td>
			
			<td align="center">
				<input type="button" value="확인" style="width:80px;height: 30px;" onclick="selectAd()" />
			</td>
		</tr>
		</c:if>
		<c:if test="${listSize <= 0 }">
			<tr>
				<td align="center">
					컨테츠가 없습니다. 컨텐츠를 먼저 등록하세요.
				</td>
			</tr>
			<tr>
				<td align="center">
					<input type="button" value="닫기" onclick="self.close()"/>
				</td>
			</tr>
		</c:if>
	</table>

</body>
</html>